/** Author: David Powell
This file produces Figure A.16
The data file was provided by Bryce Pardo
**/



clear all
set more off
set mat 11000

global dir "/jules/b/dpowell"
global DATA "${dir}/purdue/replication/DATA"
global OUTPUT "${dir}/purdue/replication/output"

use pardodata

tab year, gen(yy)

gen tripl=0
replace tripl=1 if stf==6
replace tripl=1 if stf==16
replace tripl=1 if stf==17
replace tripl=1 if stf==36
replace tripl=1 if stf==48
gen nontripl=(tripl==0)

foreach nnn of numlist 1999/2015 {
	gen tt_`nnn'=nontripl*(year==`nnn')
}



gen beta1=0
gen low1=.
gen high1=.
local nnn=1



reg score  yy* tt_* if nontripl==0 | stf==15 | stf==18 | stf==25 | stf==26 | stf==32 | stf==40 | stf==44 | stf==49 | stf==54 | stf==42  [aw=totpop], cluster(stf)

foreach nnn2 of numlist 1999/2015 {
	replace beta`nnn'=_b[tt_`nnn2'] if year==`nnn2'
	boottest tt_`nnn2', boottype(wild) weighttype(webb) reps(9999) seed(23857389)
	matrix A=r(CI)
	replace low`nnn'=A[1,1] if year==`nnn2'
	replace high`nnn'=A[1,2] if year==`nnn2'	
}
set scheme s2color  

bys year: keep if _n==1

# delimit ;

twoway(rarea low1 high1 year , color(gs14))  (connected beta1 year , color(black) msize(vtiny) sort yaxis(1)) 
, graphregion(color(white)) ylabel(,nogrid) yline(0, lpattern(dash) lcolor(gs6)) xlabel(1999(1)2015, angle(45))  legend(label(2 "Year Estimate") label(1 "95% Confidence Interval")  rows(1) order(2 1)) xtitle("Year") ytitle("Difference in PDMP Score" ,  axis(1)) ;
gr export ${OUTPUT}/figA16.eps, replace;

# delimit cr
